/**
 * 
 */
package com.taobao.wolfwolf.hibernate.dao.impl;

import java.util.List;

import com.taobao.wolfwolf.hibernate.dao.SitemDao;
import com.taobao.wolfwolf.hibernate.pojo.Sitem;

/**
 * @author Tux
 *
 * 创建时间: 2011-6-18 上午10:14:37
 */
@SuppressWarnings("unchecked")
public class SitemDaoImpl extends BaseDaoImpl implements SitemDao {

	public List<Sitem> findAll() throws Exception {
		return getHibernateTemplate().find("from Sitem");
	}

	public Sitem findById(int id) throws Exception {
		return (Sitem) getHibernateTemplate().get(Sitem.class, id);
	}

	public List<Sitem> findByName(String name) throws Exception {
		return super.findByProperty(Sitem.class, "name", name);
	}

	public List<Sitem> findByPinyin(String abbr) throws Exception {
		String hql = "from Sitem as sitem where sitem.item.pinyin like ?";
		return getHibernateTemplate().find(hql, abbr + "%");
	}

	public long getTotal() throws Exception {
		return super.countByCriteria(Sitem.class);
	}

	public List<Sitem> paging(int page, int limit) throws Exception {
		return super.findByCriteriaByPage(Sitem.class, page, limit);
	}
}
